package com.qf.swagger2204.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.swagger2204.dao.CandidateDao;
import com.qf.swagger2204.entity.Candidate;
import com.qf.swagger2204.service.CandidateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CandidateServiceImpl extends ServiceImpl<CandidateDao, Candidate> implements CandidateService {
    @Autowired
    CandidateDao candidateDao;

    @Override
    public List<Candidate> selectAll() {
        return candidateDao.selectAll();
    }

    @Override
    public Boolean selectByName(String name) {
        Boolean name1 = candidateDao.selectByName(name);
        if (name1==null){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public Candidate selectById(Integer candidateId) {
        return candidateDao.selectById(candidateId);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void updateNum(Integer id,Integer totalnum) {
        candidateDao.updateNum(id,totalnum);
    }
}
